           <?php
                    include_once 'category_model.php';
                    if(isset($_GET['Them']) && $_GET['Them']=='Thêm')
                    {
                        if($_GET['txtCateName']!=NULL)
                        {
                            $CateName=$_GET['txtCateName'];
                            $Cate=$_GET['txtCate'];
                            $visi=$_GET['txtVisible'];

                            $result=InsertCate($CateName,$Cate,$visi);
                            if($result>0)
                            {
                               echo '<h2><font color="blue"><b>Insert Success</b></font></h2>';
                               header("refresh:1;url=v_categories_manage.php");
                           } 
                            else
                            {
                                echo '<h2><font color="red"><b>Error, Please try again!!</b></font></h2>';
                                header("refresh:2;url=v_categories_manage.php");
                            }
                        }
                        else
                        {
                            echo '<h2><font color="red"><b>Warning: Category Name is not null!</b></font></h2>';
                                header("refresh:1;url=v_categories_manage.php");
                        }
                    }
                    if(isset($_GET['ID_category']))
                    {       
                        $rs=  DeleteCate($_GET['ID_category']);
                        if($rs>0)
                        {
                             echo '<h2><font color="blue"><b>Delete Success</b></font></h2>';
                             header("refresh:1;url=v_categories_manage.php");       
                        }
                    }
                    
                      if(isset($_GET['submit']) && $_GET['submit']=='Update Category')
                    {
                        if($_GET['txtCateName']!=NULL)
                        {
                            $id=$_GET['txtCateID'];
                            $CateName=$_GET['txtCateName'];
                            $Cate=$_GET['txtCate'];
                            $visi=$_GET['txtVisible'];
                            $result=  UpdateCate($CateName,$Cate,$visi,$id);
                            if($result>0)
                            {
                               echo '<h2><font color="blue"><b>Update Success</b></font></h2>';
                               header("refresh:2;url=v_categories_manage.php");
                           } 
                            else
                            {
                                echo '<h2><font color="red"><b>Error, Please try again!!</b></font></h2>';
                                header("refresh:2;url=v_categories_manage.php");
                            }
                        }
                        else
                        {
                            echo '<h2><font color="red"><b>Warning: Category Name is not null!</b></font></h2>';
                                header("refresh:1;url=v_categories_manage.php");
                        }
                    }

                ?>

